#ifndef XXLAUNCH_H
#define XXLAUNCH_H

#include <QWidget>
#include <QLabel>
#include <QThread>
#include "../Widget/XXactivityIndicatorView.h"
#include <QObject>

class XXlaunch : public QObject
{
    Q_OBJECT
public:
    XXlaunch();
    virtual ~XXlaunch();

    // config
    void configImage(const QString &imagePath);
    void configDelay(int ms);
    //void configLaunch(std::function<void(void)> launch);
    void configLaunchOnThread(std::function<void(void)> launch);
    void configLaunchOnMainThread(std::function<void(void)> launch);

    // action
    void launch();

    // signal
    Q_SIGNAL void sigFinished();

protected:
    //virtual void doThreadLaunch(QWidget *launch){Q_UNUSED(launch);}
    //virtual void doMainThreadLaunch(QWidget *launch){Q_UNUSED(launch);}

private:
    Q_SIGNAL void sigLaunch();
    Q_SLOT void onThreadLaunch();
    Q_SLOT void onMainThreadLaunch();

private:
    QWidget *_widget;
    XXactivityIndicatorView *_activityView;
    std::function<void(void)> _launchBlock;
    std::function<void(void)> _threadLaunchBlock;
    std::function<void(void)> _mainThreadLaunchBlock;

    QString _imagePath;
    int _delay;
    QThread _thread;
};

#endif
